package com.ccdc.cbpc.bigdata.server.demo.controller;

import com.ccdc.cbpc.bigdata.api.demo.client.DemoClient;
import com.ccdc.cbpc.bigdata.open.common.dto.BaseRepDTO;
import com.ccdc.cbpc.bigdata.open.common.vo.BaseRepVO;
import com.ccdc.cbpc.bigdata.server.demo.entity.DemoTab;
import com.ccdc.cbpc.bigdata.server.demo.service.DemoService;
import com.ccdc.cbpc.bigdata.server.demo.service.TKDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/demo")
public class DemoController implements DemoClient {
    @Value("${spring.application.name}")
    private String applicationName;
    @Autowired
    private TKDemoService tkDemoService;
    @Autowired
    private DemoService demoService;
    @Override
    @GetMapping("/test")
    public String test(){
        return applicationName+":"+UUID.randomUUID().toString();
    }
    @GetMapping("/list")
    public BaseRepVO<List<DemoTab>> listDemoTab(){
        return new BaseRepVO(tkDemoService.selectAll());
    }
    @GetMapping("/add")
    public BaseRepVO listDemoTab(DemoTab demoTab){
        demoService.insert(demoTab);
        return BaseRepVO.SUCCESS;
    }
}
